package fr.afcepf.al23.qualite.data;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.ResourceBundle;
import java.util.logging.Logger;

import javax.sql.DataSource;
/**
 *
 * @author Stagiaire
 *
 */
public class QualiteDataSource implements DataSource {
    /**
     *dfffff.
     */
    private static String mdp;
    /**
     *dfffff.
     */
    private static String user;
    /**
     *dfffff.
     */
    private static String url;
    @Override
    public PrintWriter getLogWriter() throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

    static {
        ResourceBundle rb = ResourceBundle.getBundle("qualite");
        try {
            Class.forName(rb.getString("driver"));
            user = rb.getString("user");
            mdp = rb.getString("password");
            url = rb.getString("url");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getLoginTimeout() throws SQLException {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void setLogWriter(PrintWriter paramArg0) throws SQLException {
        // TODO Auto-generated method stub

    }

    @Override
    public void setLoginTimeout(int paramArg0) throws SQLException {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean isWrapperFor(Class<?> paramArg0) throws SQLException {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public <T> T unwrap(Class<T> paramArg0) throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Connection getConnection() throws SQLException {
        Connection cnx = null;
        cnx = DriverManager.getConnection(url, user, mdp);
        return cnx;
    }

    @Override
    public Connection getConnection(String paramArg0, String paramArg1)
            throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

}
